
/*
 * @Author: decadent_zq 9867470+decadent-zq@user.noreply.gitee.com
 * @Date: 2023-03-31 15:57:59
 * @LastEditors: decadent_zq 9867470+decadent-zq@user.noreply.gitee.com
 * @LastEditTime: 2023-04-01 10:02:17
 * @FilePath: \absolutuniq_pc\src\main.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import SlideVerify from 'vue-monoplasty-slide-verify';
import DPlayer from 'dplayer';
import uploader from 'vue-simple-uploader';

Vue.prototype.$dPlayer = DPlayer;
Vue.use(uploader);
Vue.config.productionTip = false
// 引入 Element
Vue.use(ElementUI)

Vue.use(SlideVerify)

// 引入 axios
Vue.prototype.$axios = axios
// axios请求url前缀
axios.defaults.baseURL = 'http://101.43.223.224:8088'
// axios.defaults.baseURL = 'http://101.43.223.224:16981'
Vue.prototype.$openFile = 'http://101.43.223.224:8088'

// 图片回显统一路径
const imageUrl = 'http://101.43.223.224:8765/image/getImageById'

axios.interceptors.request.use((config) => {
  config.headers.Authorization_protal = window.sessionStorage.getItem('token')
  return config
})

// axios.interceptors.response.use((config) => {
//   if(config.data.code === 20003
//      || config.data.code === 20004 
//      || config.data.code === 20008 
//      || config.data.code === 20011 
//      || config.data.code === 20012
//      || config.data.code === 20001
//      || config.data.code === 20005
//      || config.data.code === 20009
//      || config.data.code === 20007
//      || config.data.code === 100022
//      ){
//       window.sessionStorage.removeItem('token')
//       window.sessionStorage.removeItem('userId')
//       let response = config.request.responseURL
//       console.log(response)
//       router.push('/Login')
//   } 
//   if(config.data.code !== 200){
//       if(config.data.data.errCode === 20011){
//         window.sessionStorage.removeItem('token')
//         window.sessionStorage.removeItem('userId')
//         window.sessionStorage.removeItem('avatarUrl')
//         location.reload() 
//       }
//   }
//   return config
// })

// 解决vue-router@3.0版本及以上回调形式已经改成promise api的形式了
// 返回的是一个promise，如果路由地址跳转相同, 且没有捕获到错误，
// 3.0以下版本则不会出现以下警告！！！，因路由回调问题…
// const originalPush = Router.prototype.push
// Router.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }

Vue.prototype.$imageUrl = imageUrl
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
